<script setup lang="ts">
import { reactive, ref, watch } from 'vue';
import { ForwarderRequestConfig } from '../../services/client'
import TimeSpanSelect from '../basic/TimeSpanSelect.vue';
import Version from '../basic/Version.vue';
import ClusterConfigConstants from '../../constants/ClusterConfigConstants';

const model = defineModel<ForwarderRequestConfig>({ default: new ForwarderRequestConfig() })
const modelValue = reactive(model.value)

watch(modelValue, (value) => {
    model.value = value;
})

const versionPolicies = ref(ClusterConfigConstants.HttpRequest.VersionPolicies);
</script>

<template>
    <ElFormItem prop="activityTimeout" label="Activity Timeout">
        <TimeSpanSelect v-model="modelValue.activityTimeout"></TimeSpanSelect>
    </ElFormItem>

    <ElFormItem prop="version" label="Version">
        <Version :data="modelValue.version"></Version>
    </ElFormItem>

    <ElFormItem prop="versionPolicy" label="Version Policy">
        <ElSelect v-model="modelValue.versionPolicy">
            <ElOption v-for="(p,i) in versionPolicies" :key="i" :label="p.Label" :value="p.Value">
                
            </ElOption>
        </ElSelect>
    </ElFormItem>

    <ElFormItem prop="allowResponseBuffering" label="Allow Response Buffering">
        <ElSwitch v-model="modelValue.allowResponseBuffering"></ElSwitch>
    </ElFormItem>
</template>